package com.imooc.highter_order_function

import scala.util.Random

/**
  * 偏函数： 被包在花括号内没有match的一组case语句
  *
  * 偏函数 是某种程度上的 模式匹配的简化
  */
object PartialFunction extends App{

  val names = Array("Akiho Yoshizawa","YuiHatno","Aoi Sola")

  val name = names(Random.nextInt(names.length))

  name match {

    case "Akiho Yoshizawa" => println("吉老师")
    case "YuiHatno" => println("波老师")
    case _ => println("你在说什么")

  }
  
  //A 输入参数类型  B 输出参数类型
  def sayChinese:PartialFunction[String,String] = {

    case "Akiho Yoshizawa" =>   "吉老师" 
    case "YuiHatno" =>   "波老师" 
    case _ =>   "你在说什么" 

  }

  println(sayChinese("Akiho Yoshizawa"))

}
